package com.jm.product.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.google.common.collect.Lists;

/**
 * 商品类型Entity
 * @author sunshine
 * @version 2017-06-30
 */
@Entity
@Table(name = "es_goods_type")
@Cache(region = "com.jm.cache", usage = CacheConcurrencyStrategy.READ_WRITE)
public class GoodsType extends IdEntity<Integer> implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
    @Column(name="name")
	private String name;//类型名称
    @Column(name="props")
	private String props;//props
    @Column(name="params")
	private String params;//params
    @Column(name="disabled")
	private String disabled;//disabled
    @Column(name="is_physical")
	private String isPhysical;//is_physical
    @Column(name="have_prop")
	private String haveProp;//属性
    @Column(name="have_parm")
	private String haveParm;//参数
    @Column(name="join_brand")
	private String joinBrand;//关联品牌
    @Column(name="join_spec")
	private String joinSpec;//关联规格
    @Column(name="have_field")
	private String haveField;//have_field
    @OneToMany(mappedBy = "goodsType",orphanRemoval=true,
    		cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<TypeBrandMap> typeBrandMap = Lists.newArrayList() ;
    @OneToMany(mappedBy = "goodsType",orphanRemoval=true,
    		cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<TypeSpecMap> typeSpecMap = Lists.newArrayList() ;

	public GoodsType() {
		super();
	}
	
	/**
	*
	* get 类型名称
	*
	* return name
	*/
	public String getName() {
		return this.name;
	}
	
	/**
	 * 
	 * set 类型名称
	 * 
	 * @param name
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	*
	* get props
	*
	* return props
	*/
	public String getProps() {
		return this.props;
	}
	
	/**
	 * 
	 * set props
	 * 
	 * @param props
	 */
	public void setProps(String props) {
		this.props = props;
	}
	/**
	*
	* get params
	*
	* return params
	*/
	public String getParams() {
		return this.params;
	}
	
	/**
	 * 
	 * set params
	 * 
	 * @param params
	 */
	public void setParams(String params) {
		this.params = params;
	}
	/**
	*
	* get disabled
	*
	* return disabled
	*/
	public String getDisabled() {
		return this.disabled;
	}
	
	/**
	 * 
	 * set disabled
	 * 
	 * @param disabled
	 */
	public void setDisabled(String disabled) {
		this.disabled = disabled;
	}
	/**
	*
	* get is_physical
	*
	* return isPhysical
	*/
	public String getIsPhysical() {
		return this.isPhysical;
	}
	
	/**
	 * 
	 * set is_physical
	 * 
	 * @param isPhysical
	 */
	public void setIsPhysical(String isPhysical) {
		this.isPhysical = isPhysical;
	}
	/**
	*
	* get 属性
	*
	* return haveProp
	*/
	public String getHaveProp() {
		return this.haveProp;
	}
	
	/**
	 * 
	 * set 属性
	 * 
	 * @param haveProp
	 */
	public void setHaveProp(String haveProp) {
		this.haveProp = haveProp;
	}
	/**
	*
	* get 参数
	*
	* return haveParm
	*/
	public String getHaveParm() {
		return this.haveParm;
	}
	
	/**
	 * 
	 * set 参数
	 * 
	 * @param haveParm
	 */
	public void setHaveParm(String haveParm) {
		this.haveParm = haveParm;
	}
	/**
	*
	* get 关联品牌
	*
	* return joinBrand
	*/
	public String getJoinBrand() {
		return this.joinBrand;
	}
	
	/**
	 * 
	 * set 关联品牌
	 * 
	 * @param joinBrand
	 */
	public void setJoinBrand(String joinBrand) {
		this.joinBrand = joinBrand;
	}
	/**
	*
	* get have_field
	*
	* return haveField
	*/
	public String getHaveField() {
		return this.haveField;
	}
	
	/**
	 * 
	 * set have_field
	 * 
	 * @param haveField
	 */
	public void setHaveField(String haveField) {
		this.haveField = haveField;
	}

	/**
	*
	* get 关联规格
	*
	* return joinSpec
	*/
	public String getJoinSpec() {
		return joinSpec;
	}

	/**
	 * 
	 * set 关联规格
	 * 
	 * @param joinSpec
	 */
	public void setJoinSpec(String joinSpec) {
		this.joinSpec = joinSpec;
	}

	public List<TypeBrandMap> getTypeBrandMap() {
		return typeBrandMap;
	}

	public void setTypeBrandMap(List<TypeBrandMap> typeBrandMap) {
		this.typeBrandMap = typeBrandMap;
	}

	public List<TypeSpecMap> getTypeSpecMap() {
		return typeSpecMap;
	}

	public void setTypeSpecMap(List<TypeSpecMap> typeSpecMap) {
		this.typeSpecMap = typeSpecMap;
	}

	@Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        result = prime * result + ((props == null) ? 0 : props.hashCode());
        result = prime * result + ((params == null) ? 0 : params.hashCode());
        result = prime * result + ((disabled == null) ? 0 : disabled.hashCode());
        result = prime * result + ((isPhysical == null) ? 0 : isPhysical.hashCode());
        result = prime * result + ((haveProp == null) ? 0 : haveProp.hashCode());
        result = prime * result + ((haveParm == null) ? 0 : haveParm.hashCode());
        result = prime * result + ((joinBrand == null) ? 0 : joinBrand.hashCode());
        result = prime * result + ((haveField == null) ? 0 : haveField.hashCode());
        return result;
    }
	
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        GoodsType other = (GoodsType) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        if (props == null) {
            if (other.props != null)
                return false;
        } else if (!props.equals(other.props))
            return false;
        if (params == null) {
            if (other.params != null)
                return false;
        } else if (!params.equals(other.params))
            return false;
        if (disabled == null) {
            if (other.disabled != null)
                return false;
        } else if (!disabled.equals(other.disabled))
            return false;
        if (isPhysical == null) {
            if (other.isPhysical != null)
                return false;
        } else if (!isPhysical.equals(other.isPhysical))
            return false;
        if (haveProp == null) {
            if (other.haveProp != null)
                return false;
        } else if (!haveProp.equals(other.haveProp))
            return false;
        if (haveParm == null) {
            if (other.haveParm != null)
                return false;
        } else if (!haveParm.equals(other.haveParm))
            return false;
        if (joinBrand == null) {
            if (other.joinBrand != null)
                return false;
        } else if (!joinBrand.equals(other.joinBrand))
            return false;
        if (haveField == null) {
            if (other.haveField != null)
                return false;
        } else if (!haveField.equals(other.haveField))
            return false;
        return true;
    }
	
 	@Override
    public String toString() {
        return "GoodsType [id=" + id + ",name=" + name + ",props=" + props + ",params=" + params + ",disabled=" + disabled + ",isPhysical=" + isPhysical + ",haveProp=" + haveProp + ",haveParm=" + haveParm + ",joinBrand=" + joinBrand + ",haveField=" + haveField + "]";
    }
}


